/*
 * Copyright (c) 2010-2020 DMGIS Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * DMGIS. You shall not disclose such Confidential Information
 * and shall use it only in accordance with the terms of the agreements
 * you entered into with DMGIS.
 *
 */
package com.dmgis.qxfw.dataservice.businessservice.cdtour.service.Impl;

import com.dmgis.qxfw.dataservice.businessservice.api.domain.*;
import com.dmgis.qxfw.dataservice.businessservice.api.entity.yj.*;
import com.dmgis.qxfw.dataservice.businessservice.api.entity.zy.*;
import com.dmgis.qxfw.dataservice.businessservice.common.domain.ForecastKey;
import com.dmgis.qxfw.dataservice.businessservice.common.entity.DPoint;
import com.dmgis.qxfw.dataservice.businessservice.common.entity.DZWarning;
import com.dmgis.qxfw.dataservice.businessservice.common.util.DateTime;
import com.dmgis.qxfw.dataservice.businessservice.common.util.JsonUtil;
import com.dmgis.qxfw.dataservice.businessservice.common.util.StringUtil;
import com.dmgis.qxfw.dataservice.businessservice.controller.ProcessRequestController;
import com.dmgis.qxfw.dataservice.businessservice.cdtour.service.ITourInfoSearchService;
import com.fasterxml.jackson.core.type.TypeReference;
import org.springframework.stereotype.Service;

import java.util.*;

@Service("TourInfoSearch")
public class TourInfoSearchService implements ITourInfoSearchService {

    ProcessRequestController pc = new ProcessRequestController();

    @Override
    public ForecastKey getTownNewDate() {
        // TODO Auto-generated method stub
        ForecastKey newDate = new ForecastKey();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        String[] columns = new String[]{"to_char(datechar, 'yyyy-MM-dd HH24:MI:SS') as dateChar", "timechar"};
        selectRequest.setColumns(columns);
        selectRequest.setSort(new String[]{"datechar desc", "timechar desc"});
        selectRequest.setLimit(1);
        try {
            selectParam.put("method", "tour_fcst");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            newDate = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<ForecastKey>>() {
            }).get(0);
        } catch (Exception e) {
            // TODO: handle exception
            newDate.setDateChar(DateTime.now().toDate());
            newDate.setNTimes(DateTime.now().GetHour() >= 8 && DateTime.now().GetHour() < 20 ? 8 : 20);
        }
        return newDate;
    }

    @Override
    public List<tour_fcst> getTourFcstInfo(ForecastKey forecastKey) {
        // TODO Auto-generated method stub
        // TODO 获取城市预报
        List<tour_fcst> resultList = new ArrayList<tour_fcst>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        List<String> columns = new ArrayList<String>();
        columns.add("stationid");
        columns.add("stationname");
        columns.add("longitude");
        columns.add("latitude");
        columns.add("areaname");
        columns.add("humid");
        columns.add("to_char(datechar, 'yyyy-MM-dd HH24:MI:SS') as dateChar");
        columns.add("NTimes");
        columns.add("weather1");
        columns.add("maxtemp");
        columns.add("minTemp");
        columns.add("winds");
        columns.add("windd");
        columns.add("rain");
        columns.add("advice");
        selectRequest.setColumns(columns.toArray(new String[columns.size()]));
        // 拼接where字段
        StringBuilder strWhere = new StringBuilder();
        int whereCount = 0;
        if (!StringUtil.IsNullOrEmpty(forecastKey.getStationID())) {
            whereCount++;
            strWhere.append(String.format("stationid='%s'", forecastKey.getStationID()));
        }
        if (forecastKey.getDateChar() != null) {
            strWhere.append(String.format(" and datechar='%tF'", forecastKey.getDateChar()));
        }
        if (!StringUtil.IsNullOrEmpty(forecastKey.getTimeChar())) {
            strWhere.append(String.format(" and timechar='%s'", forecastKey.getTimeChar()));
        }
        if (!StringUtil.IsNullOrEmpty(forecastKey.getTourname())) {
            strWhere.append(String.format(" and stationname='%s'", forecastKey.getTourname()));
        }
        if (forecastKey.getNTimes() != null && forecastKey.getNTimes() > 0) {
            strWhere.append(String.format(" and ntimes<='%d' and ntimes >'%d'", forecastKey.getNTimes(),
                    forecastKey.getNTimes() - 24));
//            strWhere.append(String.format(" and ntimes %% 24=0 "));
        }
        if (!StringUtil.IsNullOrEmpty(forecastKey.getForecasttype())) {
            strWhere.append(String.format(" and forecasttype='%s' ", forecastKey.getForecasttype()));
        }
        if (whereCount == 0 && !StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        selectRequest.setSort(new String[]{"datechar desc", "StationID ASC", "NTimes ASC"});
        try {
            selectParam.put("method", "tour_fcst");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<tour_fcst>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            System.err.println(e.getStackTrace());
        }
        return resultList;
    }

    @Override
    public List<warn_signal_info> getWarningInfo(String startDate, String endDate, int id) {
        // TODO 预警信号表
        List<warn_signal_info> resultList = new ArrayList<warn_signal_info>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        List<String> columns = new ArrayList<String>();
        columns.add("id");
        columns.add("Area");
        columns.add("Type");
        columns.add("Color");
        columns.add("City");
        columns.add("to_char(AnnouncedTime, 'yyyy-MM-dd HH24:MI:SS') as AnnouncedTime");
        columns.add("County");
        columns.add("Standard");
        columns.add("DefenseGuide");
        columns.add("AnnouncedTime");
        columns.add("bFree");
        columns.add("description");
        selectRequest.setColumns(columns.toArray(new String[columns.size()]));
        StringBuilder strWhere = new StringBuilder();
        int whereCount = 0;
        if (!StringUtil.IsNullOrEmpty(startDate)) {
            whereCount++;
            strWhere.append(String.format("AnnouncedTime>='%s'", startDate));
        }
        if (!StringUtil.IsNullOrEmpty(endDate)) {
            strWhere.append(String.format(" and AnnouncedTime<='%s'", endDate));
        }
        if (id > 0) {
            strWhere.append(String.format(" and id=%d", id));
        }
        strWhere.append(" and bfree=0");
        if (whereCount == 0 && !StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        try {
            selectParam.put("method", "warn_signal_info");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<warn_signal_info>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        return resultList;
    }

    @Override
    public List<base_product> getTouristProduct(int id, String productType, String startDate, String endDate) {
        // TODO Auto-generated method stub
        List<base_product> resultList = new ArrayList<base_product>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        StringBuilder strWhere = new StringBuilder();
        int whereCount = 0;
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        if (id > 0) {
            whereCount++;
            strWhere.append(String.format("id=%d", id));
        }
        if (!StringUtil.IsNullOrEmpty(productType)) {
            strWhere.append(String.format("and productType='%s'", productType));
        }
        if (!StringUtil.IsNullOrEmpty(startDate)) {
            strWhere.append(String.format(" and forecastTime>='%s'", startDate));
        }
        if (!StringUtil.IsNullOrEmpty(endDate)) {
            strWhere.append(String.format(" and forecastTime<='%s'", endDate));
        }
        if (whereCount == 0 && !StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        selectRequest.setSort(new String[]{"forecastTime desc"});
        try {
            selectParam.put("method", "base_product");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<base_product>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        return resultList;
    }


    @Override
    public List<cts_dzwarning> getTouristCtsProduct(int id, String productType, String startDate, String endDate) {
        // TODO Auto-generated method stub
        List<base_product> resultList = new ArrayList<base_product>();
        List<cts_dzwarning>  dzwarning= new ArrayList<cts_dzwarning>();
        Map<String, String> selectParam = new HashMap<String, String>();
        List<cts_dzwarning> resultList1 = new ArrayList<cts_dzwarning>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        StringBuilder strWhere = new StringBuilder();
        int whereCount = 0;
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        if (id > 0) {
            whereCount++;
            strWhere.append(String.format("id=%d", id));
        }
        if (!StringUtil.IsNullOrEmpty(productType)) {
            strWhere.append(String.format("and productType='%s'", productType));
        }
        if (!StringUtil.IsNullOrEmpty(startDate)) {
            strWhere.append(String.format(" and forecastTime>='%s'", startDate));
        }
        if (!StringUtil.IsNullOrEmpty(endDate)) {
            strWhere.append(String.format(" and forecastTime<='%s'", endDate));
        }
        if (whereCount == 0 && !StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        selectRequest.setSort(new String[]{"forecastTime desc"});
        try {
            selectParam.put("method", "base_product");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<base_product>>() {
            });
        if (resultList != null && resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                // TODO 地灾对应id的预警区
                List<dz_warning> listData = new ArrayList<dz_warning>();

                Map<String, String> selectParam1 = new HashMap<String, String>();
                RequestDataBySelect selectRequest1 = new RequestDataBySelect();
                StringBuilder strWhere1 = new StringBuilder();
                if (!StringUtil.IsNullOrEmpty(resultList.get(i).getBindid())) {
                    strWhere1.append(String.format(" and docid='%s'", resultList.get(i).getBindid()));
                }
                if (!StringUtil.IsNullOrEmpty(strWhere1.toString())) {
                    strWhere1 = strWhere1.replace(0, 4, "");
                }
                selectRequest1.setParam(strWhere1.toString());
                selectRequest1.setSort(new String[]{"datechar desc"});
                try {
                    selectParam1.put("method", "dz_warning");
                    selectParam1.put("sqlType", "select");
                    selectParam1.put("advCode", DbConfig.advCode);
                    selectParam1.put("param", JsonUtil.object2Json(selectRequest1));
                    String message1 = pc.processRequest(selectParam1);
                    listData = JsonUtil.jsonStr2TypeReference(message1, new TypeReference<List<dz_warning>>() {
                    });
                } catch (Exception e) {
                    // TODO: handle exception
                }

                if (listData != null && listData.size() > 0) {
                    for (dz_warning dzWarn : listData) {
                        cts_dzwarning ctsDzwarning = new cts_dzwarning();
                        ctsDzwarning.setPos(dzWarn.getPos());
                        ctsDzwarning.setId(resultList.get(i).getId());
                        ctsDzwarning.setProductname(resultList.get(i).getProductname());
                        ctsDzwarning.setProducttype(resultList.get(i).getProducttype());
                        ctsDzwarning.setForecasttime(resultList.get(i).getForecasttime());
                        ctsDzwarning.setMaketime(resultList.get(i).getMaketime());
                        ctsDzwarning.setMaker(resultList.get(i).getMaker());
                        ctsDzwarning.setBindid(resultList.get(i).getBindid());
                        resultList1.add(ctsDzwarning);
                    }
                }
            }
        }
        } catch (Exception e) {
                // TODO: handle exception
                System.err.println(e.getStackTrace());
            }
        return resultList1;
    }

    @Override
    public List<cts_dzwarning> getSlhxCtsProduct(int id, String productType, String startDate, String endDate) {
        // TODO Auto-generated method stub
        List<base_product> resultList = new ArrayList<base_product>();
        List<cts_dzwarning>  dzwarning= new ArrayList<cts_dzwarning>();
        Map<String, String> selectParam = new HashMap<String, String>();
        List<cts_dzwarning> resultList1 = new ArrayList<cts_dzwarning>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        StringBuilder strWhere = new StringBuilder();
        int whereCount = 0;
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        if (id > 0) {
            whereCount++;
            strWhere.append(String.format("id=%d", id));
        }
        if (!StringUtil.IsNullOrEmpty(productType)) {
            strWhere.append(String.format("and productType='%s'", productType));
        }
        if (!StringUtil.IsNullOrEmpty(startDate)) {
            strWhere.append(String.format(" and forecastTime>='%s'", startDate));
        }
        if (!StringUtil.IsNullOrEmpty(endDate)) {
            strWhere.append(String.format(" and forecastTime<='%s'", endDate));
        }
        if (whereCount == 0 && !StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        selectRequest.setSort(new String[]{"forecastTime desc"});
        try {
            selectParam.put("method", "base_product");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<base_product>>() {
            });
            if (resultList != null && resultList.size() > 0) {
                for (int i = 0; i < resultList.size(); i++) {
                    // TODO 地灾对应id的预警区
                    List<hxyj_warning> listData = new ArrayList<hxyj_warning>();

                    Map<String, String> selectParam1 = new HashMap<String, String>();
                    RequestDataBySelect selectRequest1 = new RequestDataBySelect();
                    StringBuilder strWhere1 = new StringBuilder();
                    if (!StringUtil.IsNullOrEmpty(resultList.get(i).getBindid())) {
                        strWhere1.append(String.format(" and docid='%s'", resultList.get(i).getBindid()));
                    }
                    else
                    {
                        continue;
                    }
                    if (!StringUtil.IsNullOrEmpty(strWhere1.toString())) {
                        strWhere1 = strWhere1.replace(0, 4, "");
                    }
                    selectRequest1.setParam(strWhere1.toString());
                    selectRequest1.setSort(new String[]{"datechar desc"});
                    try {
                        selectParam1.put("method", "hxyj_warning");
                        selectParam1.put("sqlType", "select");
                        selectParam1.put("advCode", DbConfig.advCode);
                        selectParam1.put("param", JsonUtil.object2Json(selectRequest1));
                        String message1 = pc.processRequest(selectParam1);
                        listData = JsonUtil.jsonStr2TypeReference(message1, new TypeReference<List<hxyj_warning>>() {
                        });
                    } catch (Exception e) {
                        // TODO: handle exception
                    }

                    if (listData != null && listData.size() > 0) {
                        for (hxyj_warning hxWarn : listData) {
                            cts_dzwarning ctsDzwarning = new cts_dzwarning();
                            ctsDzwarning.setPos(hxWarn.getPos());
                            ctsDzwarning.setId(resultList.get(i).getId());
                            ctsDzwarning.setProductname(resultList.get(i).getProductname());
                            ctsDzwarning.setProducttype(resultList.get(i).getProducttype());
                            ctsDzwarning.setForecasttime(resultList.get(i).getForecasttime());
                            ctsDzwarning.setMaketime(resultList.get(i).getMaketime());
                            ctsDzwarning.setMaker(resultList.get(i).getMaker());
                            ctsDzwarning.setBindid(resultList.get(i).getBindid());
                            resultList1.add(ctsDzwarning);
                        }
                    }
                }
            }
        } catch (Exception e) {
            // TODO: handle exception
            System.err.println(e.getStackTrace());
        }
        return resultList1;
    }

    @Override
    public ForecastKey getZhiShuNewestDate() {
        // TODO Auto-generated method stub
        // TODO Auto-generated method stub
        ForecastKey newDate = new ForecastKey();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        String[] columns = new String[]{"to_char(datechar, 'yyyy-MM-dd HH24:MI:SS') as dateChar", "timechar"};
        selectRequest.setColumns(columns);
        selectRequest.setParam("cityid like '"+DbConfig.STATIONSY+"%'");
        selectRequest.setSort(new String[]{"datechar desc", "timechar desc"});
        selectRequest.setLimit(1);
        try {
            selectParam.put("method", "zhishu");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            newDate = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<ForecastKey>>() {
            }).get(0);
        } catch (Exception e) {
            // TODO: handle exception
            newDate.setDateChar(DateTime.now().toDate());
            newDate.setTimeChar(DateTime.now().GetHour() >= 8 && DateTime.now().GetHour() < 20 ? "08" : "20");
        }
        return newDate;
    }

    @Override
    public List<Map<String, Object>> getZhiShuInfo(ForecastKey forecastKey) {
        // TODO Auto-generated method stub
        List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        // 拼接where字段
        StringBuilder strWhere = new StringBuilder();
        int whereCount = 0;
        if (!StringUtil.IsNullOrEmpty(forecastKey.getStationID())) {
            whereCount++;
            strWhere.append(String.format("cityId='%s'", forecastKey.getStationID()));
        }
        if (forecastKey.getDateChar() != null) {
            strWhere.append(String.format(" and datechar='%tF'", forecastKey.getDateChar()));
        }
        if (!StringUtil.IsNullOrEmpty(forecastKey.getTimeChar())) {
            strWhere.append(String.format(" and timechar='%s'", forecastKey.getTimeChar()));
        }
        if (!StringUtil.IsNullOrEmpty(forecastKey.getTourname())) {
            strWhere.append(String.format(" and cityname='%s'", forecastKey.getTourname()));
        }
        //strWhere.append(" and cityId like '"+ DbConfig.STATIONSY+"%'");
        if (whereCount == 0 && !StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        //selectRequest.setSort(new String[]{"datechar desc", "cityId ASC"});
        selectRequest.setSort(new String[]{"datechar desc"});
        try {
            selectParam.put("method", "zhishu");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<Map<String, Object>>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
            System.err.println(e.getStackTrace());
        }
        return resultList;
    }

    @Override
    public List<tour_stations> getAllTourStations(String stationid) {
        // TODO Auto-generated method stub
        List<tour_stations> resultList = new ArrayList<tour_stations>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
//        if (!StringUtil.IsNullOrEmpty(stationid)) {
//            selectRequest.setParam("stationid ='" + stationid + "'");
//        }
        try {
            selectParam.put("method", "tour_stations");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<tour_stations>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return resultList;
    }

    @Override
    public List<tour_actual_img> getNewestActualImg() {
        // TODO Auto-generated method stub
        List<tour_actual_img> resultList = new ArrayList<tour_actual_img>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();

        try {
            String[] columns = new String[]{"to_char(max(datechar), 'yyyy-MM-dd HH24:MI:SS') as dateChar",
                    "stationid", "stationname"};
            selectRequest.setColumns(columns);
            selectParam.put("method", "tour_actual_img");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<tour_actual_img>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        return resultList;
    }

    @Override
    public List<tour_actual_img> getImgGallery(String startDate, String endDate, String stationId) {
        // TODO Auto-generated method stub
        List<tour_actual_img> resultList = new ArrayList<tour_actual_img>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();

        try {
            String[] columns = new String[]{"to_char(max(datechar), 'yyyy-MM-dd HH24:MI:SS') as dateChar",
                    "stationid", "stationname", "imageName"};
            selectRequest.setColumns(columns);
            // 拼接where字段
            StringBuilder strWhere = new StringBuilder();
            int whereCount = 0;
            if (!StringUtil.IsNullOrEmpty(stationId)) {
                whereCount++;
                strWhere.append(String.format("stationid='%s'", stationId));
            }
            if (startDate != null) {
                strWhere.append(String.format(" and datechar>='%s'", startDate));
            }
            if (endDate != null) {
                strWhere.append(String.format(" and datechar<='%s'", endDate));
            }
            if (whereCount == 0 && !StringUtil.IsNullOrEmpty(strWhere.toString())) {
                strWhere = strWhere.replace(0, 4, "");
            }
            selectRequest.setParam(strWhere.toString());
            selectParam.put("method", "tour_actual_img");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<tour_actual_img>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        return resultList;
    }

    @Override
    public List<tour_stations> getTourStation() {
        // TODO 景点
        List<tour_stations> resultList = new ArrayList<tour_stations>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();

        try {
            selectParam.put("method", "tour_stations");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<tour_stations>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        return resultList;
    }

    @Override
    public String getstationid(tour_stations selecttour) {
        // TODO 更新
        List<tour_stations> resultList = new ArrayList<tour_stations>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        String stationid = "";
        String[] columns = new String[]{"stationid"};
        selectRequest.setColumns(columns);
        selectRequest.setParam(String.format("stationname='%s'", selecttour.getStationname()));
        try {
            selectParam.put("method", "tour_stations");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<tour_stations>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        if (resultList.size() > 0)
            stationid = resultList.get(0).getStationid().toString().trim();
        return stationid;
    }

    @Override
    public String updatePoint(tour_stations selecttour, String stationid) {
        // TODO 更新
        String result = "";
        try {
            tour_stations toursta = new tour_stations();
            toursta.setStationname(selecttour.getStationname());
            toursta.setLongitude(selecttour.getLongitude());
            toursta.setLatitude(selecttour.getLatitude());
            toursta.setText(selecttour.getText());
            toursta.setGrade(selecttour.getGrade());
            toursta.setLocation(selecttour.getLocation());
            toursta.setPeople(selecttour.getPeople());
            toursta.setPhone(selecttour.getPhone());

            Map<String, String> updateParam = new HashMap<String, String>();
            RequestDataByUpdate<String, tour_stations> updateRequest = new RequestDataByUpdate<String, tour_stations>();
            updateRequest.setData(toursta);
            updateRequest.setParam(String.format("stationid='%s'", stationid));
            updateParam.put("method", "tour_stations");
            updateParam.put("sqlType", "update");
            updateParam.put("advCode", DbConfig.advCode);
            updateParam.put("param", JsonUtil.object2Json(updateRequest));
            result = pc.processRequest(updateParam);
        } catch (Exception e) {

        }
        return result;
    }

    @Override
    public String addPoint(tour_stations selecttour) {
        // TODO 添加
        List<tour_stations> resultList = new ArrayList<tour_stations>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        String result = "";
        String id = "";
        String[] columns = new String[]{"stationid"};
        selectRequest.setColumns(columns);
        selectRequest.setSort(new String[]{"stationid DESC"});
        selectRequest.setLimit(1);
        try {
            selectParam.put("method", "tour_stations");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<tour_stations>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        int idNum = 1;
        if (resultList.size() > 0) {
            result = "exist";
            id = resultList.get(0).getStationid().toString().trim();
            idNum = Integer.parseInt(id.substring(4, 6));
            idNum++;
        }
        try {
            List<tour_stations> List_toursta = new ArrayList<tour_stations>();
            tour_stations toursta = new tour_stations();
            String res = String.format("%4s", String.valueOf(idNum));
            res = res.replaceAll("\\s", "0");
            toursta.setStationid(DbConfig.STATIONSY + res);
            toursta.setStationname(selecttour.getStationname());
            toursta.setLongitude(selecttour.getLongitude());
            toursta.setLatitude(selecttour.getLatitude());
            toursta.setText(selecttour.getText());
            toursta.setGrade(selecttour.getGrade());
            toursta.setLocation(selecttour.getLocation());
            toursta.setPeople(selecttour.getPeople());
            toursta.setPhone(selecttour.getPhone());
            List_toursta.add(toursta);
            Map<String, String> insertParam = new HashMap<String, String>();
            RequestDataByInsert<tour_stations> insertRequest = new RequestDataByInsert<tour_stations>();
            insertRequest.setData(List_toursta);
            insertParam.put("method", "tour_stations");
            insertParam.put("sqlType", "insert");
            insertParam.put("advCode", DbConfig.advCode);
            insertParam.put("param", JsonUtil.object2Json(insertRequest));
            result = pc.processRequest(insertParam);
        } catch (Exception e) {

        }
        return result;
    }

    @Override
    public String deletePoint(tour_stations selecttour) {
        // TODO 删除
        List<tour_stations> resultList = new ArrayList<tour_stations>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        String result = "";
        String stationid = "";
        String[] columns = new String[]{"stationid"};
        selectRequest.setColumns(columns);
        selectRequest.setParam(String.format("stationname='%s'", selecttour.getStationname()));
        try {
            selectParam.put("method", "tour_stations");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<tour_stations>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        if (resultList.size() > 0) {
            stationid = resultList.get(0).getStationid().trim();
            try {
                Map<String, String> deleteParam = new HashMap<String, String>();
                RequestDataByDelete<String> deleteRequest = new RequestDataByDelete<String>();
                deleteRequest.setParam(String.format("stationid='%s'", stationid));
                deleteParam.put("method", "tour_stations");
                deleteParam.put("sqlType", "delete");
                deleteParam.put("advCode", DbConfig.advCode);
                deleteParam.put("param", JsonUtil.object2Json(deleteRequest));
                result = pc.processRequest(deleteParam);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return result;
    }

    @Override
    public List<DZWarning> getDzpart(String bindid) {
        // TODO 地灾对应id的预警区
        List<dz_warning> listData = new ArrayList<dz_warning>();
        List<DZWarning> resultList = new ArrayList<DZWarning>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        StringBuilder strWhere = new StringBuilder();
        if (!StringUtil.IsNullOrEmpty(bindid)) {
            strWhere.append(String.format(" and docid='%s'", bindid));
        }
        if (!StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        selectRequest.setSort(new String[]{"datechar desc"});
        try {
            selectParam.put("method", "dz_warning");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            listData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<dz_warning>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        if (listData != null && listData.size() > 0) {
            for (dz_warning dzWarn : listData) {
                DZWarning dzWarning = new DZWarning();
                dzWarning.setDocid(dzWarn.getDocid());
                dzWarning.setDateChar(dzWarn.getDatechar());
                dzWarning.setPos(dzWarn.getPos());
                dzWarning.setGradeArea2(dzWarn.getGradearea2());
                dzWarning.setGradeArea3(dzWarn.getGradearea3());
                dzWarning.setGradeArea4(dzWarn.getGradearea4());
                dzWarning.setGradeArea5(dzWarn.getGradearea5());
                dzWarning.setDocpath(dzWarn.getDocpath());
                resultList.add(dzWarning);
            }
        }
        return resultList;
    }

    @Override
    public List<potential_points> getDisPoint(List<String> dpoint) {
        // TODO 获取关联灾害点的具体信息
        List<potential_points> listData = new ArrayList<potential_points>();
        List<DPoint> resultList = new ArrayList<DPoint>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        // 拼接where字段
        StringBuilder strWhere = new StringBuilder();
        if (dpoint != null && dpoint.size() > 0) {
            strWhere.append(" and pp_id in (");
            String tempString = "";
            for (String station : dpoint) {
                tempString += String.format("'%s',", station);
            }
            strWhere.append(tempString.substring(0, tempString.length() - 1) + ")");
        }
        if (!StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        try {
            selectParam.put("method", "potential_points");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            listData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<potential_points>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        return listData;
    }

    @Override
    public List<travel_predict> getTourfcst(String fcst) {
        // TODO 获取特色旅游
        List<travel_predict> listData = new ArrayList<travel_predict>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        StringBuilder strWhere = new StringBuilder();
        if (!StringUtil.IsNullOrEmpty(fcst)) {
            strWhere.append(String.format(" and type='%s'", fcst));
        }
        if (!StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        try {
            selectParam.put("method", "travel_predict");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            System.out.println(message);///////////
            listData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<travel_predict>>() {
            });
        } catch (Exception e) {
            e.printStackTrace();
            // TODO: handle exception
        }
        return listData;
    }

    @Override
    public List<tour_stations> getTourSta(List<String> stationnames) {
        // TODO 获取旅游景点坐标
        List<tour_stations> resultList = new ArrayList<tour_stations>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        StringBuilder strWhere = new StringBuilder();
        if (stationnames != null && stationnames.size() > 0) {
            strWhere.append(" and stationname in (");
            String tempString = "";
            for (String station : stationnames) {
                tempString += String.format("'%s',", station);
            }
            strWhere.append(tempString.substring(0, tempString.length() - 1) + ")");
        }
        if (!StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        try {
            selectParam.put("method", "tour_stations");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<tour_stations>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return resultList;
    }

    @Override
    public List<cshx_zsyb> getFireIndex(String date) {
        // TODO Auto-generated method stub
        List<cshx_zsyb> listData = new ArrayList<cshx_zsyb>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        List<String> columns = new ArrayList<String>();
        columns.add("stationid");
        columns.add("forcastdate");
        columns.add("fireindex");
        columns.add("firelevel");
        columns.add("stationname");
        columns.add("lon");
        columns.add("lat");
        selectRequest.setColumns(columns.toArray(new String[columns.size()]));
        // 拼接where字段
        StringBuilder strWhere = new StringBuilder();
        if (!StringUtil.IsNullOrEmpty(date)) {
            strWhere.append(String.format(" and forcastdate='%s'", date));
        }
        strWhere.append(" and stationid like '"+DbConfig.STATIONSY+"%'");
        if (!StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        try {
            selectParam.put("method", "cshx_zsyb");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            listData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<cshx_zsyb>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        return listData;
    }

    @Override
    public List<tour_stations> getImpdot(String stationname) {
        // TODO Auto-generated method stub
        List<tour_stations> resultList = new ArrayList<tour_stations>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        // 拼接where字段
        StringBuilder strWhere = new StringBuilder();
        if (!StringUtil.IsNullOrEmpty(stationname)) {
            strWhere.append(String.format(" and stationname='%s'", stationname));
        }
        if (!StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        try {
            selectParam.put("method", "tour_stations");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<tour_stations>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return resultList;
    }

    @Override
    public cshx_zsyb initcshxPage() {
        // TODO Auto-generated method stub
        cshx_zsyb newDate = new cshx_zsyb();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        String[] columns = new String[]{"to_char(forcastdate, 'yyyy-MM-dd HH24:MI:SS') as forcastdate"};
        selectRequest.setColumns(columns);
        selectRequest.setSort(new String[]{"forcastdate desc"});
        selectRequest.setLimit(1);
        selectRequest.setParam(" stationid like 'XT%'");
        try {
            selectParam.put("method", "cshx_zsyb");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            newDate = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<cshx_zsyb>>() {
            }).get(0);
        } catch (Exception e) {
            // TODO: handle exception
            newDate.setForcastdate(DateTime.now().toDate());
        }
        return newDate;
    }

    @Override
    public List<tour_fcst> getTourPathfcst(List<String> stationnames, String time, String sc, String sx) {
        // TODO Auto-generated method stub
        List<tour_fcst> resultList = new ArrayList<tour_fcst>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        // 拼接where字段
        StringBuilder strWhere = new StringBuilder();
        if (!StringUtil.IsNullOrEmpty(time)) {
            strWhere.append(String.format(" and datechar='%s'", time));
        }
        if (!StringUtil.IsNullOrEmpty(sc)) {
            strWhere.append(String.format(" and timechar='%s'", sc));
        }
        if (!StringUtil.IsNullOrEmpty(sx)) {
            strWhere.append(String.format(" and ntimes<='%d' and ntimes >'%d'", 24, 0));
        }
        if (stationnames != null && stationnames.size() > 0) {
            strWhere.append(" and stationname in (");
            String tempString = "";
            for (String station : stationnames) {
                tempString += String.format("'%s',", station);
            }
            strWhere.append(tempString.substring(0, tempString.length() - 1) + ")");
        }
        if (!StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        selectRequest.setSort(new String[]{"datechar desc", "StationID ASC", "NTimes ASC"});
        try {
            selectParam.put("method", "tour_fcst");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<tour_fcst>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
            System.err.println(e.getStackTrace());
        }
        return resultList;
    }

    @Override
    public List<industry_warning> getJDWarning(String warningtype, String industrytype) {
        List<industry_warning> resultList = new ArrayList<industry_warning>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        // 拼接where字段
        StringBuilder strWhere = new StringBuilder();
        if (!StringUtil.IsNullOrEmpty(warningtype)) {
            strWhere.append(String.format(" and warningtype='%s'", warningtype));
        }
        if (!StringUtil.IsNullOrEmpty(industrytype)) {
            strWhere.append(String.format(" and industrytype='%s'", industrytype));
        }
        if (!StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        selectRequest.setSort(new String[]{"datechar desc"});
        selectRequest.setLimit(1);
        try {
            selectParam.put("method", "industry_warning");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<industry_warning>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
            System.err.println(e.getStackTrace());
        }
        return resultList;
    }

    @Override
    public List<Map<String, Object>> showAirzhishu() {
        List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
        List<zhishu> result = new ArrayList<zhishu>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        selectRequest.setColumns(new String[]{"max(datechar) as datechar"});
        // 拼接where字段
        StringBuilder strWhere = new StringBuilder();
        strWhere.append("cityId like 'XT%'");
        selectRequest.setParam(strWhere.toString());
        try {
            selectParam.put("method", "zhishu");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            result = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<zhishu>>() {
            });
            if (result != null && result.size() > 0) {
                selectParam = new HashMap<String, String>();
                selectRequest = new RequestDataBySelect();
                // 拼接where字段
                strWhere = new StringBuilder();
                strWhere.append("cityId like 'XT%' and datechar ='" + result.get(0).getDatechar() + "'");
                selectRequest.setParam(strWhere.toString());
                selectRequest.setSort(new String[]{"datechar desc", "cityId ASC"});
                try {
                    selectParam.put("method", "zhishu");
                    selectParam.put("sqlType", "select");
                    selectParam.put("advCode", DbConfig.advCode);
                    selectParam.put("param", JsonUtil.object2Json(selectRequest));
                    message = pc.processRequest(selectParam);
                    resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<Map<String, Object>>>() {
                    });
                } catch (Exception e) {
                    // TODO: handle exception
                    System.err.println(e.getStackTrace());
                }
            }
        } catch (Exception e) {
            // TODO: handle exception
            System.err.println(e.getStackTrace());
        }
        return resultList;
    }

    @Override
    public List<special_fcst> showJGForecast(String staId) {
        List<special_fcst> resultList = new ArrayList<special_fcst>();
        List<special_fcst> resultList1 = new ArrayList<special_fcst>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        selectRequest.setColumns(new String[]{"max(datetime) as datetime"});
        // 拼接where字段
        StringBuilder strWhere = new StringBuilder();
        strWhere.append("type = '日出日落'");
        if (!StringUtil.IsNullOrEmpty(staId)) {
            strWhere.append(" and stationid = '" + staId + "'");
        }
        selectRequest.setParam(strWhere.toString());
        try {
            selectParam.put("method", "special_fcst");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<special_fcst>>() {
            });
            if (resultList != null && resultList.size() > 0) {
                selectParam = new HashMap<String, String>();
                selectRequest = new RequestDataBySelect();
                // 拼接where字段
                strWhere = new StringBuilder();
                strWhere.append("type = '日出日落' and datetime = '" + resultList.get(0).getDatetime() + "'");
                if (!StringUtil.IsNullOrEmpty(staId)) {
                    strWhere.append(" and stationid = '" + staId + "'");
                }
                selectRequest.setParam(strWhere.toString());
                try {
                    selectParam.put("method", "special_fcst");
                    selectParam.put("sqlType", "select");
                    selectParam.put("advCode", DbConfig.advCode);
                    selectParam.put("param", JsonUtil.object2Json(selectRequest));
                    message = pc.processRequest(selectParam);
                    resultList1 = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<special_fcst>>() {
                    });
                } catch (Exception e) {
                    // TODO: handle exception
                    System.err.println(e.getStackTrace());
                }
            }
        } catch (Exception e) {
            // TODO: handle exception
            System.err.println(e.getStackTrace());
        }
        return resultList1;
    }

    @Override
    public List<warning> getQxpart(String bindid) {
        List<warning> resultList = new ArrayList<warning>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        List<String> columns = new ArrayList<String>();
        columns.add("id");
        columns.add("Area");
        columns.add("Type");
        columns.add("Color");
        columns.add("County");
        columns.add("Standard");
        columns.add("DefenseGuide");
        columns.add("to_char(AnnouncedTime, 'yyyy-MM-dd HH24:MI:SS') as AnnouncedTime");
        columns.add("pos");
        columns.add("bFree");
        columns.add("y2path");
        selectRequest.setColumns(columns.toArray(new String[columns.size()]));
        StringBuilder strWhere = new StringBuilder();
        if (Integer.parseInt(bindid) > 0) {
            strWhere.append(String.format(" and id=%d", Integer.parseInt(bindid)));
        }
        // strWhere.append(" and bfree=0");
        if (!StringUtil.IsNullOrEmpty(strWhere.toString())) {
            strWhere = strWhere.replace(0, 4, "");
        }
        selectRequest.setParam(strWhere.toString());
        selectRequest.setSort(new String[]{"AnnouncedTime desc"});
        try {
            selectParam.put("method", "warn_signal_info");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<warning>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        return resultList;
    }



    @Override
    public Date getDZNewDate() {

        base_product newDate = new base_product();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        String[] columns = new String[]{"to_char(maketime, 'yyyy-MM-dd HH24:MI:SS') as maketime"};
        selectRequest.setColumns(columns);
        selectRequest.setParam("productType='景点地质灾害预报'");
        selectRequest.setSort(new String[]{"maketime desc"});
        selectRequest.setLimit(1);
        try {
            selectParam.put("method", "base_product");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            newDate = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<base_product>>() {
            }).get(0);
        } catch (Exception e) {
            // TODO: handle exception
            newDate.setMaketime(DateTime.now().toDate());
        }
        return newDate.getMaketime();
    }

    @Override
    public Date getsceneryDate() {
        base_product newDate = new base_product();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        String[] columns = new String[]{"to_char(maketime, 'yyyy-MM-dd HH24:MI:SS') as maketime"};
        selectRequest.setColumns(columns);
        selectRequest.setParam("productType='景观预报'");
        selectRequest.setSort(new String[]{"maketime desc"});
        selectRequest.setLimit(1);
        try {
            selectParam.put("method", "base_product");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            newDate = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<base_product>>() {
            }).get(0);
        } catch (Exception e) {
            // TODO: handle exception
            newDate.setMaketime(DateTime.now().toDate());
        }
        return newDate.getMaketime();
    }


    @Override
    public Date initslhxwaring() {
        base_product newDate = new base_product();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        String[] columns = new String[]{"to_char(forecasttime, 'yyyy-MM-dd HH24:MI:SS') as forecasttime"};
        selectRequest.setColumns(columns);
        selectRequest.setParam("productType='景点森林火险预报'");
        selectRequest.setSort(new String[]{"forecasttime desc"});
        selectRequest.setLimit(1);
        try {
            selectParam.put("method", "base_product");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            newDate = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<base_product>>() {
            }).get(0);
        } catch (Exception e) {
            // TODO: handle exception
            newDate.setForecasttime(DateTime.now().toDate());
        }
        return newDate.getForecasttime();
    }

    @Override
    public Date getsightpoint() {
        base_product newDate = new base_product();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        String[] columns = new String[]{"to_char(maketime, 'yyyy-MM-dd HH24:MI:SS') as maketime"};
        selectRequest.setColumns(columns);
        selectRequest.setParam("productType='景点预报'");
        selectRequest.setSort(new String[]{"maketime desc"});
        selectRequest.setLimit(1);
        try {
            selectParam.put("method", "base_product");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            newDate = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<base_product>>() {
            }).get(0);
        } catch (Exception e) {
            // TODO: handle exception
            newDate.setMaketime(DateTime.now().toDate());
        }
        return newDate.getMaketime();
    }

    @Override
    public List getWarningPatrtInfo() {
        List<warn_signal_info> resultList = new ArrayList<warn_signal_info>();
        Map<String, String> selectParam = new HashMap<String, String>();
        RequestDataBySelect selectRequest = new RequestDataBySelect();
        List<String> columns = new ArrayList<String>();
        columns.add("area");
        columns.add("CONCAT(type, '', color) AS type");
        columns.add("CONCAT(area, '发布', type, '', color, '预警') AS description");
        columns.add("bfree");
        selectRequest.setColumns(columns.toArray(new String[columns.size()]));
        StringBuilder strWhere = new StringBuilder();
        strWhere.append(" city like '%").append(DbConfig.STATIONNAME).append("%'");
        selectRequest.setParam(strWhere.toString());
        try {
            selectParam.put("method", "warn_signal_info");
            selectParam.put("sqlType", "select");
            selectParam.put("advCode", DbConfig.advCode);
            selectParam.put("param", JsonUtil.object2Json(selectRequest));
            String message = pc.processRequest(selectParam);
            resultList = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<warn_signal_info>>() {
            });
        } catch (Exception e) {
            // TODO: handle exception
        }
        return resultList;
    }
}
